from django.urls import path, include
from rest_framework.routers import DefaultRouter
from . import views
from .views.monitor_target_views import (
    get_monitor_targets, get_monitor_target, create_monitor_target,
    update_monitor_target, delete_monitor_target, update_priority_status,
    export_monitor_targets
)

router = DefaultRouter()
router.register(r'platforms', views.PlatformViewSet)
router.register(r'keywords', views.KeywordViewSet)
router.register(r'sentiments', views.SentimentDataViewSet)
router.register(r'targets', views.MonitorTargetViewSet)
router.register(r'alert-rules', views.AlertRuleViewSet)
router.register(r'alert-logs', views.AlertLogViewSet)
router.register(r'system-status', views.SystemStatusViewSet)
router.register(r'daily-statistics', views.DailyStatisticsViewSet)

urlpatterns = [
    # API 路由
    path('api/', include(router.urls)),
    
    # 首页数据统计API
    path('api/home-stats/', views.home_statistics, name='home-statistics'),

    # 监控目标相关API
    path('api/monitor-targets/', get_monitor_targets, name='get_monitor_targets'),
    path('api/monitor-targets/<int:target_id>/', get_monitor_target, name='get_monitor_target'),
    path('api/monitor-targets/create/', create_monitor_target, name='create_monitor_target'),
    path('api/monitor-targets/<int:target_id>/update/', update_monitor_target, name='update_monitor_target'),
    path('api/monitor-targets/<int:target_id>/delete/', delete_monitor_target, name='delete_monitor_target'),
    path('api/monitor-targets/<int:target_id>/priority/', update_priority_status, name='update_priority_status'),
    path('api/monitor-targets/export/', export_monitor_targets, name='export_monitor_targets'),
] 